package com.ng.desktop.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.ForeignKey;


/**
 * @author psabbate
 * 
 */
@Entity
@Table(name = "TH_UNIDAD_MEDIDA")
public class UnidadMedida {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID", nullable = false)
	private Long id;

    @Column(name = "NOMBRE", nullable = false, length = 60)
    private String nombre;

    @OneToMany(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_CONTACTO")
	@ForeignKey(name = "ID")
	@Cascade(value = {org.hibernate.annotations.CascadeType.ALL,
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
    private List<Equivalencia> equivalencias;

	public Long getId() {
		return id;
	}

	public String getNombre() {
		return nombre;
	}

	public List<Equivalencia> getEquivalencias() {
		return equivalencias;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setNombre(String nombre) {
		this.nombre = nombre;
	}

	public void setEquivalencias(List<Equivalencia> equivalencias) {
		this.equivalencias = equivalencias;
	}
    
	@Override
	public String toString() {
		return this.nombre;
	}
    
}
